﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/4/21 11:22:04
 * 
 * 
 * 类描述：
 * 
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;
using ueEngine.Biz.Inf.Entities.DBSupport;


namespace ueEngine.Biz.Inf.LogicEntity
{
    public class RequestSheetModel : IAccessible<RequestSheet,RequestSheetModel>
    {
        #region self
        public int Id { get; set; }

        /// <summary>
        /// 申请的招募单Id
        /// </summary>
        public int RecruitId { get; set; }

        /// <summary>
        /// 申请的职位Id
        /// </summary>
        public int PositionId { get; set; }

        /// <summary>
        /// 简历Id.
        /// 会员可以主动维护一份简历，也可以直接投递简历，然后系统会自动生成一份简历
        /// 如果是非登录人员自动生成一份简历
        /// </summary>
        public int ResumeId { get; set; }

        /// <summary>
        /// 希望获得报酬（周期与职位薪酬周期相同）
        /// </summary>
        public decimal Salary { get; set; }
        public SalaryType SalaryType { get; set; }
        /// <summary>
        /// 结算周期
        /// </summary>
        public SalaryPeriod Period { get; set; }

        /// <summary>
        /// 申请状态
        /// </summary>
        public RequestState State { get; set; }
        public string Title { get; set; }
        public DateTime PostDate { get; set; }
        /// <summary>
        /// 求职短消息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 用户
        /// </summary>
        public string UserName { get; set; }
        #endregion

        #region recruit
        /// <summary>
        /// 所申请的招募单
        /// </summary>
        public RecruitSheetModel RecruitSheet { get; set; }
        #endregion

        #region position
        /// <summary>
        /// 所申请职位
        /// </summary>
        public PositionModel Position { get; set; }
        #endregion

        protected override void Covariant(Inf.Entities.RequestSheet dbModel)
        {
            Id = dbModel.Id;
            Message = dbModel.Message;
            PositionId = dbModel.PositionId;
            RecruitId = dbModel.RecruitId;
            Period = (SalaryPeriod)dbModel.Period;
            State = (RequestState)dbModel.State;
            ResumeId = dbModel.ResumeId;
            Salary = dbModel.Salary;
            UserName = dbModel.UserName;
        }
        protected override Inf.Entities.RequestSheet Inverter(RequestSheetModel model)
        {
            return new Inf.Entities.RequestSheet()
            {
                Id = model.Id,
                Message = model.Message,
                PositionId = model.PositionId,
                RecruitId = model.RecruitId,
                ResumeId = model.ResumeId,
                Salary = model.Salary,
                UserName = model.UserName,
                Period = (int)model.Period,
                State = (int)model.State
            };
        }
        //public override RequestSheetModel Element(System.Linq.Expressions.Expression<Func<RequestSheet, bool>> where)
        //{
        //    Covariant(new RequestSheet().Get(where));
        //    return this;
        //}
        //public override List<TResult> Elements<TResult>(System.Linq.Expressions.Expression<Func<RequestSheet, bool>> where, System.Linq.Expressions.Expression<Func<RequestSheet, TResult>> select)
        //{
        //    using (Context ctx = new Context())
        //    {
        //        return ctx.RequestSheet.Where(where).Select(select).ToList();
        //    }
        //}
    }
}
